package com.synergy.stockflow.sales.controller;

import com.synergy.stockflow.model.Result;
import com.synergy.stockflow.sales.entity.OrderReturnDetails;
import com.synergy.stockflow.sales.service.OrderReturnDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/orderReturnDetails")
public class OrderReturnDetailsController {

    @Autowired
    OrderReturnDetailsService orderReturnDetailsService;
    @PutMapping
    public Result updateOrderReturnDetails(@RequestBody List<OrderReturnDetails> orderReturnDetails) {
        for(OrderReturnDetails o:orderReturnDetails){
            orderReturnDetailsService.updateById(o);
        }
        return Result.success(orderReturnDetails);
    }

    @GetMapping("/select")
    public Result selectOrderReturnDetails(@RequestParam("orderReturnDetailOrderReturnsId")String orderReturnDetailOrderReturnsId){
        List<OrderReturnDetails>orderReturnDetails = orderReturnDetailsService.select(orderReturnDetailOrderReturnsId);
        return Result.success(orderReturnDetails);
    }
}
